﻿
@{
    Layout = null;
}

<!DOCTYPE html>

<html class="x-admin-sm">
<head>
    <meta name="viewport" content="width=device-width" />
    <meta charset="UTF-8">
    <title>存货质保信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script type="text/html" id="barDemo">
        <a title="删除" href="javascript:;" lay-event="del"><i class="layui-icon">&#xe640;</i></a>
    </script>
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="proCode" placeholder="存货编码" autocomplete="off" class="layui-input" id="proCode">
                            </div>

                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="proName" placeholder="存货名称" autocomplete="off" class="layui-input" id="proName">
                            </div>

                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn layui-btn-normal" lay-filter="sreach" id="userSearch" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                            </div>
                        </form>
                    </div>

                    @if (ViewData["operate"].ToString().Contains("update"))
                    {
                        <div class="layui-card-header">
                            <button class="layui-btn layui-btn-normal" id="warrantyInfoAdd" type="button" onclick="openWin()"><i class="layui-icon"></i>添加</button>
                        </div>
                    }

                    <div class="layui-card-body layui-table-body layui-table-main">
                        <table class="layui-hide" id="warrantyInfoList" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

<script type="text/javascript">
    $(function () {
        loadData();
    })

    function loadData() {
        layui.use(['laydate', 'laypage', 'layer', 'table', 'carousel', 'upload', 'element', 'slider'], function () {
            var laydate = layui.laydate //日期
                , laypage = layui.laypage //分页
                , layer = layui.layer //弹层
                , table = layui.table //表格
                , carousel = layui.carousel //轮播
                , upload = layui.upload //上传
                , element = layui.element //元素操作
                , slider = layui.slider //滑块
            var condition = JSON.stringify(FormToJson("qForm"));

            //给table赋值
            table.render({
                elem: '#warrantyInfoList'
                , height: 380
                //, width: 1030
                , url: '../Basis/GetDataList?condition=' + condition + "&dataType=warrantyInfo" //数据接口
                , title: '质保期限'
                , page: true //开启分页
                , even: true
                , limits: [20, 50, 80, 100]
                , toolbar: true //开启工具栏，此处显示默认图标，可以自定义模板，详见文档
                , defaultToolbar: ['exports']
                , cols: [[ //表头
                    { field: 'proCode', title: '存货编码', width: 100, fixed: 'left' }
                    , { field: 'proName', title: '存货名称', width: 100, }
                    , { field: 'value', title: '质保时长（月）', width: 130, sort: true }
                    , { field: 'createtime', title: '创建时间', width: 150 }
                    , { field: 'userName', title: '创建人员名称', width: 130 }
                    , { fixed: 'right', title: '操作', width: 100, align: 'center', toolbar: '#barDemo' }
                ]]
            });

            //监听行工具事件
            table.on('tool(list)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
                var data = obj.data //获得当前行数据
                    , layEvent = obj.event; //获得 lay-event 对应的值
                if (layEvent == 'edit') {
                    InfoOpenPage('../Basis/UpdateParameter?dataId=' + data.parCode, data.parName + "-修改", "85%", "80%");
                }
                else if (layEvent == 'del') {
                    layer.confirm('确认要删除该数据？', function (index) {
                        $.ajax({
                            url: "../Basis/DelWarrantyInfo",
                            type: "post",
                            data: { dataId: data.id },
                            success: function (data) {

                                if (data.Result) {
                                    layer.msg("删除成功");
                                } else {
                                    layer.msg("删除失败");
                                }
                                loadData();
                            }
                        });
                        layer.close(index);
                    });

                }
            });


        });
    }

    function openWin() {
        InfoOpenPage("../Basis/AddWarrantyInfo?dataId=0", "存货质保期信息添加", "85%", "90%");
    }


</script>
